package com.caijin.web.controller.system;


import com.caijin.common.core.domain.Result;
import com.caijin.common.core.domain.entity.Comment;
import com.caijin.system.service.ICommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author Peas
 * @since 2021-06-05
 */
@RestController
@RequestMapping("/system/comment")
public class CommentController {

    @Autowired
    private ICommentService service;

    @ApiOperation(value = "添加评论")
    @RequestMapping(path = "/input", method = RequestMethod.POST)
    public Result input(@RequestBody Comment comment) {
        int insert = service.getBaseMapper().insert(comment);
        return insert == 0 ? Result.error() : Result.ok();
    }

    @ApiOperation(value = "删除评论")
    @RequestMapping(path = "/delete", method = RequestMethod.DELETE)
    public Result delete(@RequestParam("id") Long id) {
        return service.getBaseMapper().deleteById(id) == 0 ? Result.error() : Result.ok();
    }

}

